package v3.chapter1.daemonThread;

public class Run {

	public static void main(String[] args) {
		try {
			MyThread thread=new MyThread();
			thread.setDaemon(true);
			thread.start();
			Thread.sleep(5000);
			System.out.println("我离开 thread 对象也不再打印了，也就是停止了！");
		}catch(InterruptedException e) {
			e.printStackTrace();
		}

	}

}

class MyThread extends Thread{
	private int i=0;
	public void run(){
		try {
			while(true) {
				i++;
				System.out.println("i="+(i));
				Thread.sleep(1000);
			}
		}catch(InterruptedException e) {
			e.printStackTrace();
		}
	}
}
